<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Spring框架中的设计模式</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .pattern-card {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            transition: all 0.3s ease;
            border: 1px solid rgba(255, 255, 255, 0.2);
        }
        
        .pattern-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
        }
        
        .section-title {
            position: relative;
            display: inline-block;
        }
        
        .section-title::after {
            content: '';
            position: absolute;
            bottom: -10px;
            left: 0;
            width: 60px;
            height: 4px;
            background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
            border-radius: 2px;
        }
        
        .drop-cap {
            float: left;
            font-size: 4rem;
            line-height: 1;
            font-weight: 700;
            margin-right: 0.5rem;
            margin-top: -0.2rem;
            color: #667eea;
            font-family: 'Noto Serif SC', serif;
        }
        
        .highlight-box {
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
            color: white;
            padding: 1.5rem;
            border-radius: 1rem;
            margin: 2rem 0;
            position: relative;
            overflow: hidden;
        }
        
        .highlight-box::before {
            content: '';
            position: absolute;
            top: -50%;
            right: -50%;
            width: 200%;
            height: 200%;
            background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
            animation: pulse 3s ease-in-out infinite;
        }
        
        @keyframes pulse {
            0%, 100% { transform: scale(1); opacity: 0.5; }
            50% { transform: scale(1.1); opacity: 0.3; }
        }
        
        .pattern-icon {
            width: 60px;
            height: 60px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 1.5rem;
            margin-bottom: 1rem;
        }
        
        .mermaid {
            margin: 2rem auto;
            text-align: center;
        }
        
        .content-wrapper {
            max-width: 1200px;
            margin: 0 auto;
        }
        
        .pattern-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 2rem;
            margin: 3rem 0;
        }
        
        .pattern-item {
            background: white;
            padding: 1.5rem;
            border-radius: 0.5rem;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            transition: all 0.3s ease;
        }
        
        .pattern-item:hover {
            transform: translateY(-3px);
            box-shadow: 0 8px 12px rgba(0, 0, 0, 0.15);
        }
        
        .pattern-item h3 {
            color: #667eea;
            margin-bottom: 0.5rem;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20">
        <div class="content-wrapper px-6">
            <h1 class="text-5xl md:text-6xl font-bold mb-6 animate-pulse">
                Spring框架中的设计模式
            </h1>
            <p class="text-xl md:text-2xl opacity-90 leading-relaxed max-w-3xl">
                探索Spring框架如何巧妙运用设计模式，构建灵活、可扩展的企业级应用
            </p>
            <div class="mt-8 flex items-center space-x-6">
                <div class="flex items-center">
                    <i class="fas fa-layer-group text-3xl mr-3"></i>
                    <span class="text-lg">12+ 核心模式</span>
                </div>
                <div class="flex items-center">
                    <i class="fas fa-code text-3xl mr-3"></i>
                    <span class="text-lg">深度解析</span>
                </div>
                <div class="flex items-center">
                    <i class="fas fa-rocket text-3xl mr-3"></i>
                    <span class="text-lg">最佳实践</span>
                </div>
            </div>
        </div>
    </section>

    <!-- Introduction -->
    <section class="py-16 px-6">
        <div class="content-wrapper">
            <div class="pattern-card rounded-2xl p-8 md:p-12">
                <p class="text-lg leading-relaxed text-gray-700">
                    <span class="drop-cap">在</span>Spring框架中，设计模式的应用十分广泛，它们不仅用于解决特定问题，还帮助提高代码的可维护性、可扩展性和灵活性。从基本的创建型模式到行为型模式，再到结构型模式，Spring框架中涵盖了各种类型的设计模式。
                </p>
                <p class="text-lg leading-relaxed text-gray-700 mt-4">
                    设计模式的应用使得Spring框架具有了许多独特的特性和功能。例如，依赖注入模式使得组件之间的依赖关系更加松散，提高了代码的灵活性和可测试性；控制反转模式使得应用程序更加灵活，并且可以方便地更改对象之间的依赖关系；而面向切面编程模式则使得在应用程序中实现横切关注点更加容易。
                </p>
            </div>
        </div>
    </section>

    <!-- Pattern Overview Visualization -->
    <section class="py-16 px-6 bg-gray-50">
        <div class="content-wrapper">
            <h2 class="section-title text-3xl font-bold mb-12 text-gray-800">设计模式全景图</h2>
            <div class="bg-white rounded-2xl p-8 shadow-lg">
                <div class="mermaid">
                    graph TB
                        A[Spring设计模式] --> B[创建型模式]
                        A --> C[结构型模式]
                        A --> D[行为型模式]
                        
                        B --> B1[单例模式<br/>Singleton]
                        B --> B2[工厂模式<br/>Factory]
                        
                        C --> C1[代理模式<br/>Proxy]
                        C --> C2[适配器模式<br/>Adapter]
                        C --> C3[装饰器模式<br/>Decorator]
                        C --> C4[组合模式<br/>Composite]
                        
                        D --> D1[观察者模式<br/>Observer]
                        D --> D2[策略模式<br/>Strategy]
                        D --> D3[模板方法模式<br/>Template Method]
                        D --> D4[迭代器模式<br/>Iterator]
                        D --> D5[责任链模式<br/>Chain of Responsibility]
                        
                        style A fill:#667eea,stroke:#764ba2,stroke-width:3px,color:#fff
                        style B fill:#f093fb,stroke:#f5576c,stroke-width:2px,color:#fff
                        style C fill:#4facfe,stroke:#00f2fe,stroke-width:2px,color:#fff
                        style D fill:#fa709a,stroke:#fee140,stroke-width:2px,color:#fff
                </div>
            </div>
        </div>
    </section>

    <!-- Singleton Pattern -->
    <section class="py-16 px-6">
        <div class="content-wrapper">
            <div class="pattern-card rounded-2xl p-8 md:p-12">
                <div class="pattern-icon">
                    <i class="fas fa-cube"></i>
                </div>
                <h2 class="section-title text-3xl font-bold mb-8 text-gray-800">单例模式</h2>
                <p class="text-lg leading-relaxed text-gray-700 mb-6">
                    单例模式是一种创建型设计模式，它确保一个类只有一个实例，并提供一个全局访问点。这种模式通常用于需要全局访问的类，例如工厂类、日志类、线程池等。
                </p>
                
                <div class="highlight-box">
                    <h3 class="text-2xl font-bold mb-4 relative z-10">
                        <i class="fas fa-lightbulb mr-2"></i>Spring中的应用场景
                    </h3>
                    <div class="grid md:grid-cols-2 gap-4 relative z-10">
                        <div>
                            <h4 class="font-semibold mb-2">
                                <i class="fas fa-check-circle mr-2"></i>Bean的默认作用域
                            </h4>
                            <p class="text-sm opacity-90">Spring容器中Bean默认为单例模式，确保资源高效利用</p>
                        </div>
                        <div>
                            <h4 class="font-semibold mb-2">
                                <i class="fas fa-check-circle mr-2"></i>容器实例管理
                            </h4>
                            <p class="text-sm opacity-90">BeanFactory和ApplicationContext本身也是单例的</p>
                        </div>
                        <div>
                            <h4 class="font-semibold mb-2">
                                <i class="fas fa-check-circle mr-2"></i>依赖注入
                            </h4>
                            <p class="text-sm opacity-90">单例Bean可以被注入到其他Bean中，实现共享</p>
                        </div>
                        <div>
                            <h4 class="font-semibold mb-2">
                                <i class="fas fa-check-circle mr-2"></i>线程安全
                            </h4>
                            <p class="text-sm opacity-90">Spring保证了单例Bean的线程安全性</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Factory Pattern -->
    <section class="py-16 px-6 bg-gray-50">
        <div class="content-wrapper">
            <div class="pattern-card rounded-2xl p-8 md:p-12">
                <div class="pattern-icon">
                    <i class="fas fa-industry"></i>
                </div>
                <h2 class="section-title text-3xl font-bold mb-8 text-gray-800">工厂模式</h2>
                <p class="text-lg leading-relaxed text-gray-700 mb-6">
                    工厂模式是一种创建型设计模式，旨在提供一种封装对象创建逻辑的方式，从而隐藏了具体对象的实例化过程。它通过一个工厂类来负责创建对象，将对象的创建与使用相分离。
                </p>
                
                <div class="mermaid">
                    graph LR
                        A[客户端] --> B[工厂接口]
                        B --> C[具体工厂A]
                        B --> D[具体工厂B]
                        C --> E[产品A]
                        D --> F[产品B]
                        
                        style B fill:#667eea,stroke:#764ba2,stroke-width:2px,color:#fff
                        style C fill:#f093fb,stroke:#f5576c,stroke-width:2px,color:#fff
                        style D fill:#f093fb,stroke:#f5576c,stroke-width:2px,color:#fff
                </div>
                
                <div class="pattern-grid mt-8">
                    <div class="pattern-item">
                        <h3 class="text-xl font-semibold">
                            <i class="fas fa-cog mr-2"></i>BeanFactory接口
                        </h3>
                        <p class="text-gray-600">负责管理和创建Bean对象，隐藏创建细节</p>
                    </div>
                    <div class="pattern-item">
                        <h3 class="text-xl font-semibold">
                            <i class="fas fa-puzzle-piece mr-2"></i>FactoryBean接口
                        </h3>
                        <p class="text-gray-600">用于创建复杂对象或代理对象，支持自定义创建逻辑</p>
                    </div>
                    <div class="pattern-item">
                        <h3 class="text-xl font-semibold">
                            <i class="fas fa-magic mr-2"></i>@Autowired注解
                        </h3>
                        <p class="text-gray-600">实现依赖注入，自动从容器获取